<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
{# 显示文章标题和作者 #}
{% for post in post_list %}
    <h1>{{ post.name }}</h1>
    {% load cache %}
{#    {% cache 60 sidebar %}  {# 模板指定缓存信息 #}
        <h2>{{ post.author_name }}</h2>
{#    {% endcache %}#}
    <h3>{{ post.category }}</h3>
{% endfor %}

{% if post_list.has_previous %}
    <a href="/page/{{ post_list.previous_page_number }}">
        上一页
    </a>
{% endif %}

{#  总的页码  for循环遍历取值#}
{% for index in post_list.paginator.page_range %}
    {#<span>{{ post_list.number|add:-3 }}</span><br>#}
    {# post_list.number 表示的是当前是第几页 #}
    {% if index > post_list.number|add:-2 and index < post_list.number|add:2 %}
        <a href="/page/{{ index }}/">{{ index }}</a>
    {% endif %}

{% endfor %}

{% if post_list.has_next %}
    <a href="/page/{{ post_list.next_page_number }}">
        下一页
    </a>
{% endif %}


</body>
</html>